package com.huabo.contract.service.impl;

import com.hbfk.util.PageInfo;
import com.huabo.contract.config.DateBaseConfig;
import com.huabo.contract.oracle.entity.TblCyhwEconomiccontract;
import com.huabo.contract.oracle.mapper.TblCyhwEconomiccontractMapper;
import com.huabo.contract.service.TblCyhwEconomiccontractService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

@Service
public class TblCyhwEconomiccontractServiceImpl implements TblCyhwEconomiccontractService {

    @Resource
    private TblCyhwEconomiccontractMapper tblCyhwEconomiccontractMapper;

    @Override
    public void findListByPageInfo(PageInfo<TblCyhwEconomiccontract> pageInfo, BigDecimal orgid) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblCyhwEconomiccontractMapper.findListByPageInfo(pageInfo, orgid));
            pageInfo.setTotalRecord(tblCyhwEconomiccontractMapper.findListByPageInfoCount(orgid));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("data", pageInfo);
        } else {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblCyhwEconomiccontractMapper.findListByPageInfo(pageInfo, orgid));
            pageInfo.setTotalRecord(tblCyhwEconomiccontractMapper.findListByPageInfoCount(orgid));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("data", pageInfo);
        }
    }

    @Override
    public void findListByPage(PageInfo<TblCyhwEconomiccontract> pageInfo, String userid, BigDecimal orgid) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblCyhwEconomiccontractMapper.findListByPage(pageInfo, userid, orgid));
            pageInfo.setTotalRecord(tblCyhwEconomiccontractMapper.findListByPageCount(userid, orgid));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("data", pageInfo);
        } else {
            Map<String, Object> resultMap = new HashMap<String, Object>(0);
            pageInfo.setTlist(tblCyhwEconomiccontractMapper.findListByPage(pageInfo, userid, orgid));
            pageInfo.setTotalRecord(tblCyhwEconomiccontractMapper.findListByPageCount(userid, orgid));
            resultMap.put("code", "1");
            resultMap.put("msg", "访问接口成功");
            resultMap.put("data", pageInfo);
        }
    }
}
